window.addEventListener('load', function () {
    let init = document.querySelector('.init') ///初始化按钮
    let logout = document.querySelector('.logout') ///退出按钮

    ///   -----------点击初始化----------

    init.addEventListener('click', function () {
        axios({
            url: '/init/data',
        }).then(res => {
            console.log(res);
            if (res.data.code == 0) {
                toastr.success(res.data.message)
            } else if (res.data.code == 1) {
                toastr.warning(res.data.message)
            }
        })
    })

    ///   -----------切换图表  排他----------
    let allA = document.querySelectorAll('.nav ul a')
    console.log(allA);
    allA.forEach(function (ele, index) {
        ele.addEventListener('click', function () {
            document.querySelector('.nav ul a.active').classList.remove('active')
            ele.classList.add('active')
        })
    })

    ///   -----------退出  ----------
    logout.addEventListener('click', function () {
        localStorage.removeItem('token')
        location.href = './login.html'
    })
})